#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import sys
# [ Imports ]
import Quartz
import fire
import AppKit
import objc
pid=717
print Quartz.CGEvent
exit()
def sendKeyto(pid):
    # pid = 715  # get/input a real pid from somewhere for the target app.
    point = Quartz.CGPoint()
    print point
    point.x = 100  # get a target x from somewhere
    point.y = 100  # likewise, your target y from somewhere
    events = [Quartz.CGEventCreateKeyboardEvent(objc.NULL, 0, True),
              Quartz.CGEventCreateKeyboardEvent(objc.NULL, 0, False)]
    left_mouse_down_event = Quartz.CGEventCreateMouseEvent(objc.NULL, Quartz.kCGEventLeftMouseDown, point,
                                                           Quartz.kCGMouseButtonLeft)
    left_mouse_up_event = Quartz.CGEventCreateMouseEvent(objc.NULL, Quartz.kCGEventLeftMouseUp, point,
                                                         Quartz.kCGMouseButtonLeft)

    # Quartz.CGEventPostToPid(pid, left_mouse_down_event)
    # Quartz.CGEventPostToPid(pid, left_mouse_up_event)
    # Quartz.CGEventPostToPid(pid, events[0])
    # Quartz.CGEventPostToPid(pid, events[0])
    # Quartz.CGEventPostToPid(pid, events[0])
    # Quartz.CGEventPostToPid(pid, events[0])
    # Quartz.CGEventPostToPid(pid, events[0])
    # CGEventPostToPSN
    # Quartz.CGEventPostToPid(pid, events[1])
    print events


appname = "Sublime Text"
if sys.platform == "darwin":
    import applescript
    from AppKit import NSWorkspace
    from Quartz import (
        CGWindowListCopyWindowInfo,
        kCGWindowListOptionOnScreenOnly,
        kCGNullWindowID,
        CGEventPostToPSN,
        CGEventPostToPid
    )

    activeAppName = NSWorkspace.sharedWorkspace().activeApplication()
    print activeAppName
    print Quartz
    print objc
    # sendKeyto(pid)
